package com.loveprogrammer.battle;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName Hero
 * @Description 简单的英雄模型
 * @Author admin
 * @Date 2024/2/20 16:57
 * @Version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Hero {

    String name = "hero";

    int attack =  10;

    int speed = 10;

    int hp = 100;

    public Hero(String name) {
        this.name = name;
    }

    /***
     * 模拟攻击
     * @param hero
     */
    public void attack(Hero hero) {
        if(hero.getHp() > 0) {
            hero.setHp(hero.getHp() - getAttack());
            System.out.println(getName() + "攻击," + hero.getName() + "生命值减少" + getAttack());
        }
    }
}
